package com.kit.data.kitopeso.adapter;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.kit.data.kitopeso.base.BaseBindingAdapter1;
import com.kit.data.kitopeso.databinding.KitoFbSubmitItem1Binding;

import java.util.List;

public class FbTypeAdapter extends BaseBindingAdapter1<String, KitoFbSubmitItem1Binding> {


    int index = -1;

    public FbTypeAdapter(List<String> dataList) {
        super(dataList);
    }

    @SuppressLint("SetTextI18n")
    @Override
    protected void bindData(KitoFbSubmitItem1Binding binding, String item, int position) {
        binding.tvTitle.setText(item);
        if (position == 1 || position == 4) {
            ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            binding.tvTitle.setLayoutParams(params);
        } else {
            ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
            binding.tvTitle.setLayoutParams(params);
        }
        binding.tvTitle.setSelected(index == position);
        binding.tvTitle.setOnClickListener(v -> {
            index = position;
            updateAllData();
        });
    }

    @Override
    protected int getItemType(String item) {
        return 0;
    }

    @Override
    protected KitoFbSubmitItem1Binding createBinding(LayoutInflater inflater, ViewGroup parent, int viewType) {
        return KitoFbSubmitItem1Binding.inflate(inflater, parent, false);
    }

    public int getIndex() {
        return index;
    }

    public void setIndex(int index) {
        this.index = index;
    }
}
